﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using FluentNHibernate.Mapping;
using PinCity.Models.Content;
using PinCity.Models.Accounts;

namespace PinCity.ORM
{
    /// <summary>
    /// Class, that maps PinCity.Models.Content.Post
    /// entity with Fluent NHibernate. Any updates to the 
    /// PinCity.Models.Content.Post should be reflected here.
    /// </summary>
    public class PostMapping : ClassMap<Post>
    {
        public PostMapping()
        {
            this.Table("NewsPosts");
            this.Id(x => x.ID).GeneratedBy.Native();
            this.Map(x => x.Caption);
            this.Map(x => x.Text);
            this.Map(x => x.Rating);
            this.References<User>(x => x.Author);
        }
    }

    /// <summary>
    /// Class, that maps PinCity.Models.Content.Marker
    /// entity with Fluent NHibernate. Any updates to the 
    /// PinCity.Models.Content.Marker should be reflected here.
    /// </summary>
    public class MarkerMapping : ClassMap<Pin>
    {
        public MarkerMapping()
        {
            this.Table("Markers");
            this.Id(x => x.ID).GeneratedBy.Native();
            this.Map(x => x.Caption);
            this.Map(x => x.Text);
            this.Map(x => x.Rating);
            this.Map(x => x.Latitude);
            this.Map(x => x.Longtitude);
            this.Map(x => x.Address);
            this.Map(x => x.PictureUrl);
            this.References<User>(x => x.Author);

        }
    }

    /// <summary>
    /// Class, that maps PinCity.Models.Content.PinComment
    /// entity with Fluent NHibernate. Any updates to the 
    /// PinCity.Models.Content.MarkerCommentcted here.
    /// </summary>
    public class MarkerCommentMapping : ClassMap<PinComment>
    {
        public MarkerCommentMapping()
        {
            this.Table("MarkerComments");
            this.Id(x => x.ID).GeneratedBy.Native();
            this.Map(x => x.Caption);
            this.Map(x => x.Text);
            this.Map(x => x.Rating);
            this.References<Pin>(x => x.Marker);
            this.References<User>(x => x.Author);

        }
    }

    /// <summary>
    /// Class, that maps PinCity.Models.Content.PostComment
    /// entity with Fluent NHibernate. Any updates to the 
    /// PinCity.Models.Content.PostCommentcted here.
    /// </summary>
    public class PostCommentMapping : ClassMap<PostComment>
    {
        public PostCommentMapping()
        {
            this.Table("PostComments");
            this.Id(x => x.ID).GeneratedBy.Native();
            this.Map(x => x.Caption);
            this.Map(x => x.Text);
            this.Map(x => x.Rating);
            this.References<Post>(x => x.Post);
            this.References<User>(x => x.Author);

        }
    }
}